//
//  LoginViewController.m
//  Rockval
//
//  Created by TuanNT on 4/27/14.
//  Copyright (c) 2014 TNL. All rights reserved.
//

#import "LoginViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
	self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
	if (self) {
		// Custom initialization
	}
	return self;
}

- (void)viewDidLoad {
	[super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning];
	// Dispose of any resources that can be recreated.
}

/*
   #pragma mark - Navigation

   // In a storyboard-based application, you will often want to do a little preparation before navigation
   - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
   {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
   }
 */

//================================ IBACTIONS ================================
#pragma mark -
#pragma mark IBACTIONS

- (IBAction)btnLogin_TouchUpInside:(id)sender {
	[self dismissKeyboard];

	[self showHud];
	[[DataManager sharedInstance] loginWithEmail:_txtEmail.text password:_txtPassword.text andBlock: ^(BOOL isSuccess) {
	    [self hideHud];
	    if (isSuccess) {
	        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RockvalStoryboard" bundle:[NSBundle mainBundle]];
	        MFSideMenuContainerViewController *container = [storyboard instantiateViewControllerWithIdentifier:@"MFSideMenuContainerViewController"];
	        BaseNavigationController *centerNavigationController = [storyboard instantiateViewControllerWithIdentifier:@"CenterNavigationController"];
	        BaseNavigationController *leftSideMenuController = [storyboard instantiateViewControllerWithIdentifier:@"SideMenuNavigationController"];

	        [container setLeftMenuViewController:leftSideMenuController];
	        [container setCenterViewController:centerNavigationController];
	        [container setPanMode:MFSideMenuPanModeNone];
	        [container setMenuWidth:self.view.window.bounds.size.width];
	        [self.view.window setRootViewController:container];
		}
	    else {
	        DLog();
		}
	}];
}

//================================ METHODS ================================
#pragma mark -
#pragma mark METHODS

@end
